<template>
	<view class="login">
		<!-- <image class="bg_img" src="../../static/image/login.jpg" mode=""></image> -->
		
		<view class="login_confirm">
			<view class="tit">
				Welcome back!
			</view>
			<view class="img">
				<text class="iconfont icon-user-man-full"></text>
			</view>
			<!-- <view class="header_box">
				<view class="header_portrait iconfont icon-user-man-full"></view>
			</view> -->
			<view class="login_box">
				<view class="" style="margin-bottom: 20rpx;overflow: hidden;">
					<u-tabs :list="list1" @click="getTabs" :activeStyle="{color: '#1364d3'}"
						:inactiveStyle="{color: '#353535'}" lineColor="#1364d3" :itemStyle="{width:'50%',padding:'0',height:'45px',textAlign:'right'}"></u-tabs>
					<view class="tab_line"></view>
				</view>
				<view class="mar_top ">
					<password ref="password" v-show="tabIndex === 1"></password>
					<arch-code ref="mobilelogin" v-show="tabIndex === 0"></arch-code>
				</view>
				<view class="mar_tops" style="padding-top: 40rpx;">
					<u-button type="primary" shape="circle" text="登录" @click="confirmLogin" :customStyle="{'padding': '0 20px',background:'#51cfff',borderColor:'#51cfff'}">
					</u-button>
				</view>
			</view>

			<view class=" flex flex_align agreement">
				<u-checkbox-group v-model="checked">
					<u-checkbox name="同意" shape="square"></u-checkbox>
				</u-checkbox-group>
				<view class="">
					若手机号未注册将进入注册流程, 注册即为同意<text @click="agreement" class="copy">《同意协议》</text>,短信验证码为【教管壹】开头的短信，请注意查收。
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Password from './component/password.vue'
	import ArchCode from './component/arthCode.vue'
	import {
		login,
		mobilelogin
	} from '@/api/login.js'
	export default {
		components: {
			Password,
			ArchCode
		},
		data() {
			return {
				list1: [{
					name: '验证码登录',
				}, {
					name: '密码登录',
				}],
				tabIndex: 0,
				checked: ['同意']
			}
		},
		methods: {
			getTabs(item) {
				this.tabIndex = item.index
			},
			confirmLogin() {
				if (!this.checked.length) return this.$u.toast('请先同意协议');
				if (this.tabIndex) {
					this.$refs.password.getLogin()
				} else {
					this.$refs.mobilelogin.getmobilelogin()
				}
			},
			agreement() {
				uni.navigateTo({
					url: '/pages/serviceAgreement/index'
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #f5f2ff;
	}
</style>

<style lang="scss" scoped>
	.login {
		height: 100vh;
		// width: 100%;
		background: url();
		background-size: 100% 100%;
		background-attachment: fixed;
		background-repeat: no-repeat;
		.tit{
			position: absolute;
			color: #5a9be3;
			font-size: 40rpx;
			font-weight: 700;
			top: -50rpx;
		}
		.img{
			position: absolute;
			top: -90rpx;
			right: 70rpx;
			border-radius: 50%;
			background-color: #fff;
			padding: 10rpx;
			text{
				color: #ccd0eb;
				font-size: 125rpx;
			}
		}
		.mar_tops {
			margin-top: 40rpx;
		}

		.bg_img {
			position: fixed;
			left: 0;
			height: 100%;
			width: 100%;
		}
		.agreement {
			font-size: 20rpx;
			// margin-top: 40rpx;
			color: #323e4d;
			letter-spacing: 2rpx;
			position: absolute;
			bottom: -12vh;
			// width: 60%;
			// left: 50%;
			// transform: translateX(-50%);
		}

		.login_confirm {
			position: absolute;
			top: 60%;
			left: 50%;
			transform: translate(-50%, -55%);
			width: 86%;
			height: 640rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			border-radius: 20px;
			background-color: #fff;
			padding-bottom: 20rpx;
			.header_box {
				text-align: center;
			}
			.header_portrait {
				padding: 10px;
				background: #fff;
				color: #ccd0eb;
				border-radius: 50%;
				font-size: 60px;
				display: inline-block;
			}
		}
		.login_box {
			width: 80%;
			position: relative;
			left: 50%;
			transform: translateX(-50%);
			display: flex;
			flex-direction: column;
			justify-content: space-around;
		}
	}

	.copy {
		color: #566cb4;
		font-size: 10px;
		line-height: 14px;
		// text-decoration: underline;
	}
	.tab_line{
		// width: 90%;
		margin: 0 4%;
		height: 4rpx;
		background: #ebebeb;
		margin-top: -8rpx;
	}
</style>
